import {ref} from 'vue'
import {defineStore} from 'pinia'
import {setItem, getItem} from '@/utils/local'
import {CONFIG, PRIMARY_COLOR} from '@/utils/constant'

const configStore = defineStore(CONFIG, () => {
	const primaryColor = ref(getItem(PRIMARY_COLOR) || '#346fff')    // 全局主色
	
	function updatePrimaryColor(newColor) {
		if (!newColor) return
		setItem(PRIMARY_COLOR, newColor)
		primaryColor.value = newColor
	}
	
	return {
		primaryColor,
		updatePrimaryColor
	}
})

export default configStore

